///This has been deprecated in favor of the CommandQueue
///June 20, 2007................t.w.
package com.as3.timbot.data.lib
{
	import com.as3.timbot.data.collections.Queue;
	import com.as3.timbot.net.ILoader;
	import com.as3.timbot.net.LoadEvent;
	
	import flash.display.Sprite;
	import flash.display.Loader;
	import flash.net.URLRequest;
	import flash.events.*;
	
	public class LoaderQueue
	{
		private var __loadList:Queue;
		private var myLoader:Loader;
		private var _scope:Sprite;

		public function LoaderQueue():void
		{
			__loadList = new Queue();
			
		}
		/**
		* Adds an item to the queue
		*/
		public function add(value:ILoader):void
		{
			__loadList.enqueue(value);
		}
		public function startLoad():void
		{
			//fire a queue loadstart event........t.w.
			loadNext();
		}
		public function loadNext():void
		{
			if(!__loadList.isEmpty()){
				var loadObject:Object = __loadList.dequeue();
				loadObject.addEventListener(Event.COMPLETE,completeHandler);
				loadObject.load();
			}else{
				//fire a queue load finished event...............t.w.
			}
		}
		public function completeHandler(ev:LoadEvent):void
		{
			//from here, the queue really needs to bounce the finished
			//event out....t.w.
			loadNext();
		}
		/*private function loadInitHandler(ev:Event):void
		{
			//fire a queue element load finished event..............t.w.
			//this should be checking if the 'show' attribute is set
			_scope.addChild(myLoader.content);
			startLoad();
		}
		
		private function progressHandler(ev:ProgressEvent):void
		{
			//fire a queue element load progress event............t.w.
			trace("loading "+Math.floor(ev.bytesLoaded/1024)+" / "+Math.floor(ev.bytesTotal/1024)+" kb");
		}
		private function loadCompleteHandler(ev:Event):void
		{
			//handle the load completed here....t.w.
		}
		private function timeOutHandler(ev:Event):void
		{
			//handle a load timeout here......t.w.
		}*/
		public function isEmpty() : Boolean
		{
			return __loadList.isEmpty();
		}
		public function getElements() : Array
		{
			return __loadList.getElements();
		}
		public function getLength() : Number
		{
			return __loadList.getLength();
		}
	}
};